﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// The Settings Flyout item template is documented at http://go.microsoft.com/fwlink/?LinkId=273769

namespace CustomStyles.Views
{
    public sealed partial class Settings : SettingsFlyout
    {
        public Settings()
        {
            this.InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        { ChangeTheme(new Uri("ms-appx:/Styles/Red.xaml", UriKind.Absolute)); }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        { ChangeTheme(new Uri("ms-appx:/Styles/Green.xaml", UriKind.Absolute)); }

        private void Button_Click_2(object sender, RoutedEventArgs e)
        { ChangeTheme(new Uri("ms-appx:/Styles/Blue.xaml", UriKind.Absolute)); }

        void ChangeTheme(Uri theme)
        {
            var t = new ResourceDictionary { Source = theme };
            var r = new ResourceDictionary { MergedDictionaries = { t } };
            App.Current.Resources = r;
            var f = (Window.Current.Content as Frame);
            f.Navigate(f.Content.GetType());
            f.GoBack();
        }
    }
}
